﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FB.Data.Housekeep.Models
{
    [Table("SecuritiesCommissionSummaries")]
    public class SecuritiesCommission
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public long ID { get; set; }

        [Required]
        public DateTime TradeDate { get; set; }

        [Required]
        [MaxLength(16)]
        public string InvoiceNo { get; set; }

        [Required]
        [MaxLength(16)]
        public string ClientCode { get; set; }

        [Required]
        [MaxLength(256)]
        public string ClientName { get; set; }

        [Required]
        [MaxLength(2)]
        public string AccType { get; set; }

        [MaxLength(8)]
        public string AECode { get; set; }

        [MaxLength(256)]
        public string AEName { get; set; }

        [Required]
        [MaxLength(8)]
        public string StkCode { get; set; }

        [Required]
        [MaxLength(2)]
        public string BuySell { get; set; }
        
        [Required]
        public decimal AVGPrice { get; set; }

        [Required]
        public long Quantity { get; set; }
        [Required]
        public decimal Brokage { get; set; }
        [Required]
        public decimal AERebate { get; set; }
        [Required]
        public decimal AEComm { get; set; }
        [Required]
        public decimal Turnover { get; set; }

        [Required]
        public decimal NetAmount { get; set; }

        [Required]
        public decimal BrokageRate { get; set; }

        public decimal MonthlyRebateAmt { get; set; }
        public decimal ActualSalary { get; set; }

        [MaxLength(8)]
        public string ChannelCode { get; set; }
        public decimal MinTurnover { get; set; }
        public decimal MinHSERebate { get; set; }

        [Required]
        [MaxLength(256)]
        public string CreateBy { get; set; }

        public DateTime CreateDate { get; set; }

        public virtual ICollection<SecuritiesCommissionDetail> TradeDetails { get; set; }

        public SecuritiesCommission()
        {
            TradeDetails = new List<SecuritiesCommissionDetail>();
        }
    }


    public class SecuritiesCommissionDetail
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public long ID { get; set; }

        public long TradeID { get; set; }

        [Required]
        public decimal Price { get; set; }

        [Required]
        public long Quantity { get; set; }

        [ForeignKey("TradeID")]
        public virtual SecuritiesCommission Trade { get; set; }
    }
}
